package nku.csc360;


@SuppressWarnings("rawtypes")
public class Octagon extends GeometricObject implements Cloneable, Comparable{

	private int side; //Data field for length of side
	
	//Null Argument Constructor
    public Octagon() {
    	
    }
    
    // W/Argument Constructor
    public Octagon(int a){
    	side = a;
    }
    
    //Testing my class
	public static void main(String... Args)throws CloneNotSupportedException{
		Octagon raj = new Octagon(5);
		System.out.println("Octogan Perimeter is :" + raj.getPerimeter());
		System.out.println("Octogan Area is :" + raj.getArea());
		Octagon y = (Octagon) raj.clone();
		System.out.println(raj.compareTo(y));
		System.out.println("Octogan Clone Perimeter is :" + y.getPerimeter());
		System.out.println("Octogan Clone Area is :" + y.getArea());
	}
	
    //Setter for value of side
    public void setSide(int side){
    	this.side = side;
    }
    
    //Getter for value of side
    public int getSide(){
    	return side;
    }
    
    //Overridign tostring method
    public String toString() {
      return "created on " + getDateCreated() + "\ncolor: " + getColor() +
        " and filled: " + isFilled();
    }

    //Overriding abstract method for area
    public double getArea(){
    	return (2 + 4/(2^(1/2)) * side * side);
  	
    }
  
    // Overriding abstract method for perimeter
    public double getPerimeter(){
    	return (side * 8);
  	  
    }
    
    //Overriding clone
    public Object clone()throws CloneNotSupportedException{
    	return super.clone();
    }
    
    //Overriding compareTo method to compare using area if i want to compare using area just change getArea to getPermieter
    public int compareTo(Object o){
    	GeometricObject test = (GeometricObject)o;
    	if (this.getArea() == test.getArea()){
    		return 0;
    	}
    	else if (this.getArea() > test.getArea())
    		return -1;
    	else 
    		return +1;
    }
}